home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 3.iso / screensavers / saver17.zip / VoodooLights / Sources / tex.c < prev    next >
C/C++ Source or Header  |  1997-07-24  |  2KB  |  64 lines

  1. /*------------------------------------------------------/
  2. /                                                        /
  3. /    Copyright 1997, SΘrgio Durte <smd@di.fct.unl.pt>    /
  4. /                                                        /
  5. /------------------------------------------------------*/
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <math.h>
  10. #include <string.h>
  11. #include <glide.h>
  12.  
  13. #include "defines.h"
  14.  
  15. #include "tex.h"
  16. #include "win.h"
  17.  
  18.  
  19. extern char tex_path[] ;
  20.  
  21. GrMipMapId_t tex_InitTexture( char *name )
  22. {
  23.     GrMipMapId_t handle ;
  24.     Gu3dfInfo info;
  25.     char path[ 512 ] ;
  26.  
  27.     sprintf(path, "%s/%s", tex_path, name ) ;
  28.  
  29.     if ( gu3dfGetInfo( path, & info ) ) {
  30.         if ( ( info.data = malloc( info.mem_required ) ) == 0 ) 
  31.             win_MessageBox( 1, "Glide Error", "Not enough core memory." ) ;
  32.     
  33.         
  34.         
  35.         if ( !gu3dfLoad( path, & info ) ) 
  36.             win_MessageBox( 1, "Glide Error", "Cannot load texture." ) ;
  37.  
  38.  
  39.         handle = guTexAllocateMemory( GR_TMU0, GR_MIPMAPLEVELMASK_BOTH, 
  40.                                   info.header.width, info.header.height,
  41.                                   info.header.format,
  42.                                   GR_MIPMAP_NEAREST,
  43.                                   info.header.small_lod, info.header.large_lod,
  44.                                   info.header.aspect_ratio,
  45.                                   GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP,
  46.                                   GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR,
  47.                                   0.0,
  48.                                   FXFALSE ) ;
  49.  
  50.         if ( handle == GR_NULL_MIPMAP_HANDLE )
  51.             win_MessageBox( 1, "Glide Error", "Not enough tmu memory." ) ;
  52.  
  53.         guTexDownloadMipMap( handle, info.data, NULL ) ;
  54.  
  55.         return handle ;
  56.     }
  57.     else win_MessageBox( 1, "Glide Error", "Cannot find texture files." ) ;
  58.  
  59. }
  60.  
  61. void tex_SetTexSource(GrMipMapId_t src )
  62. {
  63.     guTexSource( src ) ;
  64. }